package com.cap.dreamcircle.View.Adapter;

import android.content.Context;
import android.view.ViewGroup;

import com.cap.dreamcircle.Common.RecyclerView.BaseItem;
import com.cap.dreamcircle.Common.RecyclerView.MultiTypeListAdapter;
import com.cap.dreamcircle.Model.Bean.AdCommentEntity;
import com.cap.dreamcircle.View.Adapter.Item.AdCommentsItem;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by liucxu on 2017/11/8.
 */

public class AdCommentsAdapter extends MultiTypeListAdapter<AdCommentEntity> {

    private List<AdCommentEntity> datas = new ArrayList<>();
    private Context mContext;

    public AdCommentsAdapter(Context c, List<AdCommentEntity> sources) {
        if (sources != null) {
            datas.clear();
            datas.addAll(sources);
            mContext = c;
        }
    }

    @Override
    public AdCommentEntity getItem(int viewType, int position) {
        return datas.get(position);
    }

    @Override
    public BaseItem<AdCommentEntity> createItemView(ViewGroup parent, int viewType) {
        return new AdCommentsItem(parent);
    }

    @Override
    public int getItemCount() {
        return datas.size();
    }

    public void setDatas(List<AdCommentEntity> sources) {
        if (sources != null) {
            datas.clear();
            datas.addAll(sources);
            notifyDataSetChanged();
        }
    }
}
